function loginyz() {
    var un = $("#username").val();
    var spd = $("#password").val();
    if (spd != '') {
        $('#psdts').hide();
    } else {
        $('#psdts').show();
    }
    if (un != '') {
        $('#unts').hide();
    } else {
        $('#unts').show();
    }
    if (spd != '' && un != '') {
        loginin();
    }
}

function goin(e) {
    if (e.keyCode == 13) {
        loginin();
    }
}

//登录
function loginin() {
    var role = $("input[name='auth']:checked").val();
    if (role == "admin" || role == "super_admin") {
        $.get(commonobj.ip + "admin/login", {
            account: $("#username").val(),
            pwd: $("#password").val(),
            role: $("input[name='auth']:checked").val()
        }).success(function (data) {
            if (data.code == "0") {
                var user = data.data;
                user.account = $("#username").val();
                user.pwd = $("#password").val();
                localStorage.setItem("user", JSON.stringify(user));
                if (user.role == "super_admin") {
                    window.document.location.href = commonobj.getRootPath() + '/views/super_admin.html';
                } else if (user.role == "admin") {
                    window.document.location.href = commonobj.getRootPath() + '/views/admin.html';
                }
            }
        }).error(function (data) {
            $('#modal').show();
            $('#content').html(data.responseJSON.msg);
        });
    } else if (role == "mall") {
        $.get(commonobj.ip + "mall/login", {
            account: $("#username").val(),
            pwd: $("#password").val(),
            role: "mall"
        }).success(function (data) {
            if (data.code == "0") {
                var user = data.data;
                user.account = $("#username").val();
                user.pwd = $("#password").val();
                localStorage.setItem("user", JSON.stringify(user));
                window.document.location.href = commonobj.getRootPath() + '/views/mall.html';
            }
        }).error(function (data) {
            $('#modal').show();
            $('#content').html(data.responseJSON.msg);
        });
    }
}